<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Application launching</title>
<meta name="generator" content="DocBook XSL Stylesheets V1.76.1">
<link rel="home" href="index.html" title="GDK 3 参考手册">
<link rel="up" href="reference.html" title="API参考">
<link rel="prev" href="gdk3-X-Window-System-Interaction.html" title="X Window System Interaction">
<link rel="next" href="gdk3-Testing.html" title="Testing">
<meta name="generator" content="GTK-Doc V1.17 (XML mode)">
<link rel="stylesheet" href="style.css" type="text/css">
</head>
<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
<table class="navigation" id="top" width="100%" summary="Navigation header" cellpadding="2" cellspacing="2">
<tr valign="middle">
<td><a accesskey="p" href="gdk3-X-Window-System-Interaction.html"><img src="left.png" width="24" height="24" border="0" alt="Prev"></a></td>
<td><a accesskey="u" href="reference.html"><img src="up.png" width="24" height="24" border="0" alt="Up"></a></td>
<td><a accesskey="h" href="index.html"><img src="home.png" width="24" height="24" border="0" alt="Home"></a></td>
<th width="100%" align="center">GDK 3 参考手册</th>
<td><a accesskey="n" href="gdk3-Testing.html"><img src="right.png" width="24" height="24" border="0" alt="Next"></a></td>
</tr>
<tr><td colspan="5" class="shortcuts">
<a href="#gdk3-Application-launching.synopsis" class="shortcut">Top</a>
                   | 
                  <a href="#gdk3-Application-launching.description" class="shortcut">Description</a>
</td></tr>
</table>
<div class="refentry">
<a name="gdk3-Application-launching"></a><div class="titlepage"></div>
<div class="refnamediv"><table width="100%"><tr>
<td valign="top">
<h2><span class="refentrytitle"><a name="gdk3-Application-launching.top_of_page"></a>Application launching</span></h2>
<p>Application launching — Startup notification for applications</p>
</td>
<td valign="top" align="right"></td>
</tr></table></div>
<div class="refsynopsisdiv">
<a name="gdk3-Application-launching.synopsis"></a><h2>Synopsis</h2>
<pre class="synopsis">
#include &lt;gdk/gdk.h&gt;

                    <a class="link" href="gdk3-Application-launching.html#GdkAppLaunchContext" title="GdkAppLaunchContext">GdkAppLaunchContext</a>;
<a class="link" href="gdk3-Application-launching.html#GdkAppLaunchContext" title="GdkAppLaunchContext"><span class="returnvalue">GdkAppLaunchContext</span></a> * <a class="link" href="gdk3-Application-launching.html#gdk-app-launch-context-new" title="gdk_app_launch_context_new ()">gdk_app_launch_context_new</a>        (<em class="parameter"><code><span class="type">void</span></code></em>);
<span class="returnvalue">void</span>                <a class="link" href="gdk3-Application-launching.html#gdk-app-launch-context-set-display" title="gdk_app_launch_context_set_display ()">gdk_app_launch_context_set_display</a>  (<em class="parameter"><code><a class="link" href="gdk3-Application-launching.html#GdkAppLaunchContext" title="GdkAppLaunchContext"><span class="type">GdkAppLaunchContext</span></a> *context</code></em>,
                                                         <em class="parameter"><code><a class="link" href="gdk3-GdkDisplay.html#GdkDisplay" title="GdkDisplay"><span class="type">GdkDisplay</span></a> *display</code></em>);
<span class="returnvalue">void</span>                <a class="link" href="gdk3-Application-launching.html#gdk-app-launch-context-set-screen" title="gdk_app_launch_context_set_screen ()">gdk_app_launch_context_set_screen</a>   (<em class="parameter"><code><a class="link" href="gdk3-Application-launching.html#GdkAppLaunchContext" title="GdkAppLaunchContext"><span class="type">GdkAppLaunchContext</span></a> *context</code></em>,
                                                         <em class="parameter"><code><a class="link" href="gdk3-GdkScreen.html#GdkScreen" title="GdkScreen"><span class="type">GdkScreen</span></a> *screen</code></em>);
<span class="returnvalue">void</span>                <a class="link" href="gdk3-Application-launching.html#gdk-app-launch-context-set-desktop" title="gdk_app_launch_context_set_desktop ()">gdk_app_launch_context_set_desktop</a>  (<em class="parameter"><code><a class="link" href="gdk3-Application-launching.html#GdkAppLaunchContext" title="GdkAppLaunchContext"><span class="type">GdkAppLaunchContext</span></a> *context</code></em>,
                                                         <em class="parameter"><code><a href="../glib/glib-Basic-Types.html#gint"><span class="type">gint</span></a> desktop</code></em>);
<span class="returnvalue">void</span>                <a class="link" href="gdk3-Application-launching.html#gdk-app-launch-context-set-timestamp" title="gdk_app_launch_context_set_timestamp ()">gdk_app_launch_context_set_timestamp</a>
                                                        (<em class="parameter"><code><a class="link" href="gdk3-Application-launching.html#GdkAppLaunchContext" title="GdkAppLaunchContext"><span class="type">GdkAppLaunchContext</span></a> *context</code></em>,
                                                         <em class="parameter"><code><a href="../glib/glib-Basic-Types.html#guint32"><span class="type">guint32</span></a> timestamp</code></em>);
<span class="returnvalue">void</span>                <a class="link" href="gdk3-Application-launching.html#gdk-app-launch-context-set-icon" title="gdk_app_launch_context_set_icon ()">gdk_app_launch_context_set_icon</a>     (<em class="parameter"><code><a class="link" href="gdk3-Application-launching.html#GdkAppLaunchContext" title="GdkAppLaunchContext"><span class="type">GdkAppLaunchContext</span></a> *context</code></em>,
                                                         <em class="parameter"><code><a href="../gio/GIcon.html"><span class="type">GIcon</span></a> *icon</code></em>);
<span class="returnvalue">void</span>                <a class="link" href="gdk3-Application-launching.html#gdk-app-launch-context-set-icon-name" title="gdk_app_launch_context_set_icon_name ()">gdk_app_launch_context_set_icon_name</a>
                                                        (<em class="parameter"><code><a class="link" href="gdk3-Application-launching.html#GdkAppLaunchContext" title="GdkAppLaunchContext"><span class="type">GdkAppLaunchContext</span></a> *context</code></em>,
                                                         <em class="parameter"><code>const <span class="type">char</span> *icon_name</code></em>);
</pre>
</div>
<div class="refsect1">
<a name="gdk3-Application-launching.description"></a><h2>Description</h2>
<p>
GdkAppLaunchContext is an implementation of <a href="../gio/GAppInfo.html#GAppLaunchContext"><span class="type">GAppLaunchContext</span></a> that
handles launching an application in a graphical context. It provides
startup notification and allows to launch applications on a specific
screen or workspace.
</p>
<div class="example">
<a name="id2964537"></a><p class="title"><b>Example 5. Launching an application</b></p>
<div class="example-contents"><pre class="programlisting">
GdkAppLaunchContext *context;

context = gdk_display_get_app_launch_context (display);

gdk_app_launch_context_set_screen (screen);
gdk_app_launch_context_set_timestamp (event-&gt;time);

if (!g_app_info_launch_default_for_uri ("http://www.gtk.org", context, &amp;error))
  g_warning ("Launching failed: %s\n", error-&gt;message);

g_object_unref (context);
</pre></div>
</div>
<p><br class="example-break">
</p>
</div>
<div class="refsect1">
<a name="gdk3-Application-launching.details"></a><h2>Details</h2>
<div class="refsect2">
<a name="GdkAppLaunchContext"></a><h3>GdkAppLaunchContext</h3>
<pre class="programlisting">typedef struct {
  GAppLaunchContext parent_instance;

  GdkDisplay *display;
  GdkScreen *screen;
  gint workspace;
  guint32 timestamp;
  GIcon *icon;
  char *icon_name;
} GdkAppLaunchContext;
</pre>
<p>
</p>
</div>
<hr>
<div class="refsect2">
<a name="gdk-app-launch-context-new"></a><h3>gdk_app_launch_context_new ()</h3>
<pre class="programlisting"><a class="link" href="gdk3-Application-launching.html#GdkAppLaunchContext" title="GdkAppLaunchContext"><span class="returnvalue">GdkAppLaunchContext</span></a> * gdk_app_launch_context_new        (<em class="parameter"><code><span class="type">void</span></code></em>);</pre>
<div class="warning" style="margin-left: 0.5in; margin-right: 0.5in;">
<h3 class="title">Warning</h3>
<p><code class="literal">gdk_app_launch_context_new</code> has been deprecated since version 3.0 and should not be used in newly-written code. Use <a class="link" href="gdk3-GdkDisplay.html#gdk-display-get-app-launch-context" title="gdk_display_get_app_launch_context ()"><code class="function">gdk_display_get_app_launch_context()</code></a> instead</p>
</div>
<p>
Creates a new <a class="link" href="gdk3-Application-launching.html#GdkAppLaunchContext" title="GdkAppLaunchContext"><span class="type">GdkAppLaunchContext</span></a>.
</p>
<div class="variablelist"><table border="0">
<col align="left" valign="top">
<tbody><tr>
<td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td>
<td>a new <a class="link" href="gdk3-Application-launching.html#GdkAppLaunchContext" title="GdkAppLaunchContext"><span class="type">GdkAppLaunchContext</span></a>
</td>
</tr></tbody>
</table></div>
<p class="since">Since 2.14</p>
</div>
<hr>
<div class="refsect2">
<a name="gdk-app-launch-context-set-display"></a><h3>gdk_app_launch_context_set_display ()</h3>
<pre class="programlisting"><span class="returnvalue">void</span>                gdk_app_launch_context_set_display  (<em class="parameter"><code><a class="link" href="gdk3-Application-launching.html#GdkAppLaunchContext" title="GdkAppLaunchContext"><span class="type">GdkAppLaunchContext</span></a> *context</code></em>,
                                                         <em class="parameter"><code><a class="link" href="gdk3-GdkDisplay.html#GdkDisplay" title="GdkDisplay"><span class="type">GdkDisplay</span></a> *display</code></em>);</pre>
<div class="warning" style="margin-left: 0.5in; margin-right: 0.5in;">
<h3 class="title">Warning</h3>
<p><code class="literal">gdk_app_launch_context_set_display</code> has been deprecated since version 3.0 and should not be used in newly-written code. Use <a class="link" href="gdk3-GdkDisplay.html#gdk-display-get-app-launch-context" title="gdk_display_get_app_launch_context ()"><code class="function">gdk_display_get_app_launch_context()</code></a> instead</p>
</div>
<p>
Sets the display on which applications will be launched when
using this context. See also <a class="link" href="gdk3-Application-launching.html#gdk-app-launch-context-set-screen" title="gdk_app_launch_context_set_screen ()"><code class="function">gdk_app_launch_context_set_screen()</code></a>.
</p>
<div class="variablelist"><table border="0">
<col align="left" valign="top">
<tbody>
<tr>
<td><p><span class="term"><em class="parameter"><code>context</code></em> :</span></p></td>
<td>a <a class="link" href="gdk3-Application-launching.html#GdkAppLaunchContext" title="GdkAppLaunchContext"><span class="type">GdkAppLaunchContext</span></a>
</td>
</tr>
<tr>
<td><p><span class="term"><em class="parameter"><code>display</code></em> :</span></p></td>
<td>a <a class="link" href="gdk3-GdkDisplay.html#GdkDisplay" title="GdkDisplay"><span class="type">GdkDisplay</span></a>
</td>
</tr>
</tbody>
</table></div>
<p class="since">Since 2.14</p>
</div>
<hr>
<div class="refsect2">
<a name="gdk-app-launch-context-set-screen"></a><h3>gdk_app_launch_context_set_screen ()</h3>
<pre class="programlisting"><span class="returnvalue">void</span>                gdk_app_launch_context_set_screen   (<em class="parameter"><code><a class="link" href="gdk3-Application-launching.html#GdkAppLaunchContext" title="GdkAppLaunchContext"><span class="type">GdkAppLaunchContext</span></a> *context</code></em>,
                                                         <em class="parameter"><code><a class="link" href="gdk3-GdkScreen.html#GdkScreen" title="GdkScreen"><span class="type">GdkScreen</span></a> *screen</code></em>);</pre>
<p>
Sets the screen on which applications will be launched when
using this context. See also <a class="link" href="gdk3-Application-launching.html#gdk-app-launch-context-set-display" title="gdk_app_launch_context_set_display ()"><code class="function">gdk_app_launch_context_set_display()</code></a>.
</p>
<p>
If both <em class="parameter"><code>screen</code></em> and <em class="parameter"><code>display</code></em> are set, the <em class="parameter"><code>screen</code></em> takes priority.
If neither <em class="parameter"><code>screen</code></em> or <em class="parameter"><code>display</code></em> are set, the default screen and
display are used.
</p>
<div class="variablelist"><table border="0">
<col align="left" valign="top">
<tbody>
<tr>
<td><p><span class="term"><em class="parameter"><code>context</code></em> :</span></p></td>
<td>a <a class="link" href="gdk3-Application-launching.html#GdkAppLaunchContext" title="GdkAppLaunchContext"><span class="type">GdkAppLaunchContext</span></a>
</td>
</tr>
<tr>
<td><p><span class="term"><em class="parameter"><code>screen</code></em> :</span></p></td>
<td>a <a class="link" href="gdk3-GdkScreen.html#GdkScreen" title="GdkScreen"><span class="type">GdkScreen</span></a>
</td>
</tr>
</tbody>
</table></div>
<p class="since">Since 2.14</p>
</div>
<hr>
<div class="refsect2">
<a name="gdk-app-launch-context-set-desktop"></a><h3>gdk_app_launch_context_set_desktop ()</h3>
<pre class="programlisting"><span class="returnvalue">void</span>                gdk_app_launch_context_set_desktop  (<em class="parameter"><code><a class="link" href="gdk3-Application-launching.html#GdkAppLaunchContext" title="GdkAppLaunchContext"><span class="type">GdkAppLaunchContext</span></a> *context</code></em>,
                                                         <em class="parameter"><code><a href="../glib/glib-Basic-Types.html#gint"><span class="type">gint</span></a> desktop</code></em>);</pre>
<p>
Sets the workspace on which applications will be launched when
using this context when running under a window manager that
supports multiple workspaces, as described in the
<a class="ulink" href="http://www.freedesktop.org/Standards/wm-spec" target="_top">Extended
Window Manager Hints</a>.
</p>
<p>
When the workspace is not specified or <em class="parameter"><code>desktop</code></em> is set to -1,
it is up to the window manager to pick one, typically it will
be the current workspace.
</p>
<div class="variablelist"><table border="0">
<col align="left" valign="top">
<tbody>
<tr>
<td><p><span class="term"><em class="parameter"><code>context</code></em> :</span></p></td>
<td>a <a class="link" href="gdk3-Application-launching.html#GdkAppLaunchContext" title="GdkAppLaunchContext"><span class="type">GdkAppLaunchContext</span></a>
</td>
</tr>
<tr>
<td><p><span class="term"><em class="parameter"><code>desktop</code></em> :</span></p></td>
<td>the number of a workspace, or -1</td>
</tr>
</tbody>
</table></div>
<p class="since">Since 2.14</p>
</div>
<hr>
<div class="refsect2">
<a name="gdk-app-launch-context-set-timestamp"></a><h3>gdk_app_launch_context_set_timestamp ()</h3>
<pre class="programlisting"><span class="returnvalue">void</span>                gdk_app_launch_context_set_timestamp
                                                        (<em class="parameter"><code><a class="link" href="gdk3-Application-launching.html#GdkAppLaunchContext" title="GdkAppLaunchContext"><span class="type">GdkAppLaunchContext</span></a> *context</code></em>,
                                                         <em class="parameter"><code><a href="../glib/glib-Basic-Types.html#guint32"><span class="type">guint32</span></a> timestamp</code></em>);</pre>
<p>
Sets the timestamp of <em class="parameter"><code>context</code></em>. The timestamp should ideally
be taken from the event that triggered the launch.
</p>
<p>
Window managers can use this information to avoid moving the
focus to the newly launched application when the user is busy
typing in another window. This is also known as 'focus stealing
prevention'.
</p>
<div class="variablelist"><table border="0">
<col align="left" valign="top">
<tbody>
<tr>
<td><p><span class="term"><em class="parameter"><code>context</code></em> :</span></p></td>
<td>a <a class="link" href="gdk3-Application-launching.html#GdkAppLaunchContext" title="GdkAppLaunchContext"><span class="type">GdkAppLaunchContext</span></a>
</td>
</tr>
<tr>
<td><p><span class="term"><em class="parameter"><code>timestamp</code></em> :</span></p></td>
<td>a timestamp</td>
</tr>
</tbody>
</table></div>
<p class="since">Since 2.14</p>
</div>
<hr>
<div class="refsect2">
<a name="gdk-app-launch-context-set-icon"></a><h3>gdk_app_launch_context_set_icon ()</h3>
<pre class="programlisting"><span class="returnvalue">void</span>                gdk_app_launch_context_set_icon     (<em class="parameter"><code><a class="link" href="gdk3-Application-launching.html#GdkAppLaunchContext" title="GdkAppLaunchContext"><span class="type">GdkAppLaunchContext</span></a> *context</code></em>,
                                                         <em class="parameter"><code><a href="../gio/GIcon.html"><span class="type">GIcon</span></a> *icon</code></em>);</pre>
<p>
Sets the icon for applications that are launched with this
context.
</p>
<p>
Window Managers can use this information when displaying startup
notification.
</p>
<p>
See also <a class="link" href="gdk3-Application-launching.html#gdk-app-launch-context-set-icon-name" title="gdk_app_launch_context_set_icon_name ()"><code class="function">gdk_app_launch_context_set_icon_name()</code></a>.
</p>
<div class="variablelist"><table border="0">
<col align="left" valign="top">
<tbody>
<tr>
<td><p><span class="term"><em class="parameter"><code>context</code></em> :</span></p></td>
<td>a <a class="link" href="gdk3-Application-launching.html#GdkAppLaunchContext" title="GdkAppLaunchContext"><span class="type">GdkAppLaunchContext</span></a>
</td>
</tr>
<tr>
<td><p><span class="term"><em class="parameter"><code>icon</code></em> :</span></p></td>
<td>a <a href="../gio/GIcon.html"><span class="type">GIcon</span></a>, or <a href="../glib/glib-Standard-Macros.html#NULL:CAPS"><code class="literal">NULL</code></a>. <span class="annotation">[<acronym title="NULL is ok, both for passing and for returning."><span class="acronym">allow-none</span></acronym>]</span>
</td>
</tr>
</tbody>
</table></div>
<p class="since">Since 2.14</p>
</div>
<hr>
<div class="refsect2">
<a name="gdk-app-launch-context-set-icon-name"></a><h3>gdk_app_launch_context_set_icon_name ()</h3>
<pre class="programlisting"><span class="returnvalue">void</span>                gdk_app_launch_context_set_icon_name
                                                        (<em class="parameter"><code><a class="link" href="gdk3-Application-launching.html#GdkAppLaunchContext" title="GdkAppLaunchContext"><span class="type">GdkAppLaunchContext</span></a> *context</code></em>,
                                                         <em class="parameter"><code>const <span class="type">char</span> *icon_name</code></em>);</pre>
<p>
Sets the icon for applications that are launched with this context.
The <em class="parameter"><code>icon_name</code></em> will be interpreted in the same way as the Icon field
in desktop files. See also <a class="link" href="gdk3-Application-launching.html#gdk-app-launch-context-set-icon" title="gdk_app_launch_context_set_icon ()"><code class="function">gdk_app_launch_context_set_icon()</code></a>.
</p>
<p>
If both <em class="parameter"><code>icon</code></em> and <em class="parameter"><code>icon_name</code></em> are set, the <em class="parameter"><code>icon_name</code></em> takes priority.
If neither <em class="parameter"><code>icon</code></em> or <em class="parameter"><code>icon_name</code></em> is set, the icon is taken from either
the file that is passed to launched application or from the <a href="../gio/GAppInfo.html"><span class="type">GAppInfo</span></a>
for the launched application itself.
</p>
<div class="variablelist"><table border="0">
<col align="left" valign="top">
<tbody>
<tr>
<td><p><span class="term"><em class="parameter"><code>context</code></em> :</span></p></td>
<td>a <a class="link" href="gdk3-Application-launching.html#GdkAppLaunchContext" title="GdkAppLaunchContext"><span class="type">GdkAppLaunchContext</span></a>
</td>
</tr>
<tr>
<td><p><span class="term"><em class="parameter"><code>icon_name</code></em> :</span></p></td>
<td>an icon name, or <a href="../glib/glib-Standard-Macros.html#NULL:CAPS"><code class="literal">NULL</code></a>. <span class="annotation">[<acronym title="NULL is ok, both for passing and for returning."><span class="acronym">allow-none</span></acronym>]</span>
</td>
</tr>
</tbody>
</table></div>
<p class="since">Since 2.14</p>
</div>
</div>
</div>
<div class="footer">
<hr>
          Generated by GTK-Doc V1.17</div>
</body>
</html>